package com.example.androidhive;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainScreenActivity extends Activity {

	Button btnViewProducts;
	Button btnNewProduct;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.main_screen);

		// Buttons
		this.btnViewProducts = (Button) this.findViewById(R.id.btnViewProducts);
		this.btnNewProduct = (Button) this.findViewById(R.id.btnCreateProduct);

		// view products click event
		this.btnViewProducts.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View view) {
				// Launching All products Activity
				Intent i = new Intent(MainScreenActivity.this
						.getApplicationContext(), AllProductsActivity.class);
				MainScreenActivity.this.startActivity(i);

			}
		});

		// view products click event
		this.btnNewProduct.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View view) {
				// Launching create new product activity
				Intent i = new Intent(MainScreenActivity.this
						.getApplicationContext(), NewProductActivity.class);
				MainScreenActivity.this.startActivity(i);

			}
		});
	}
}
